import request from '@/utils/request'
import {getToken} from "@/utils/auth";

export function login(data) {
  return request({
    url: '/admin/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/admin/info',
    method: 'get',
    headers: {
      Authorization: "Bearer " + token
    }
  })
}

export function logout() {
  return request({
    url: '/admin/logout',
    method: 'post'
  })
}

export function addNewAdmin(societyId) {
  let creationTime=Date.now();
  return request({
    url: '/admin/addAdmin',
    method: 'post',
    data: {societyId,creationTime},
    headers: {
      Authorization: "Bearer " + getToken()
    }
  })
}

export function getAllAdmin(pageNo, limit){
  return request({
    url:'/admin/getAllAdmin',
    method:'get',
    headers: {
      Authorization: "Bearer " + getToken()
    },
    params:{pageNo, limit}
  })
}

export function delSocietyAdmin(ids){
  return request({
    method:'post',
    url:'/admin/delete',
    headers: {
      Authorization: "Bearer " + getToken()
    },
    data:{ids}
  })
}